import java.util.*;

public class Offer50 {
    public char firstUniqChar1(String s) {
        if (s==null||s.length()==0) return ' ';
        Queue<Character> queue = new LinkedList<>();
        HashMap<Character, Integer> map = new HashMap<>(24);
        for (int i = 0; i < s.length(); i++) {
            if (!map.containsKey(s.charAt(i))){
                map.put(s.charAt(i),1);
                queue.add(s.charAt(i));
            }else {
                queue.remove(s.charAt(i));
            }
        }
        return queue.size()==0?' ':queue.peek();
    }
    public char firstUniqChar2(String s) {
        if (s==null||s.length()==0) return ' ';
        Map<Character, Boolean> map = new HashMap<>(24);
        for (int i = 0; i < s.length(); i++) {
            map.put(s.charAt(i),!map.containsKey(s.charAt(i)));
        }
        for (int i = 0; i < s.length(); i++) {
            if (map.get(s.charAt(i))) return s.charAt(i);
        }
        return ' ';
    }
    public char firstUniqChar(String s) {
        if (s==null||s.length()==0) return ' ';
        Map<Character, Boolean> map = new LinkedHashMap<>();
        for (int i = 0; i < s.length(); i++) {
            map.put(s.charAt(i),!map.containsKey(s.charAt(i)));
        }

        for (Map.Entry<Character, Boolean> entry : map.entrySet()) {
            if (entry.getValue()) return entry.getKey();
        }
        return ' ';
    }
}
